<?php
namespace  app\admin\controller;

use app\admin\logic\BannerLogic;
use app\admin\logic\BrandLogic;
use app\BaseController;
use think\facade\Request;
use think\facade\View;


//品牌页
class Brand extends BaseController
{
    //品牌列表
    public function brand()
    {
        //where拼接   list($where,$whereOr) //list接数组
        list($where, $whereOr) = BrandLogic::brandWhere();
        $data = BrandLogic::brandData();
        View::assign($data);
        //语句
        $brand = \app\admin\model\Brand::brandList($where, $whereOr,$data);
        //留值
        $page=$brand->render();
        View::assign(['brand'=> $brand,'page'=>$page]);
        return View::fetch();
    }
        //品牌添加
     public function brandAdd(){
        if (Request::isPost()){
            $post=Request::post();
            $data=BrandLogic::brandAdd($post);
            $res=\app\admin\model\Brand::getBrandAdd($data);
            if ($res){
                $this->success('添加成功',url('brand'));
            }else{
                $this->error('添加失败');
            }
        }else{
            return View::fetch();
        }
     }
        //品牌修改
          public function brandEdit(){
            if (Request::isPost()){
                $post=Request::post();
                $data=BrandLogic::brandEdit($post);
                $res=\app\admin\model\Brand::getBrandEdit([],$data);
                if ($res){
                    $this->success('修改成功',url('brand'));
                }else{
                    $this->error('修改失败');
                }

            }else{
                $get=Request::get();
                $find=\app\admin\model\Brand::getBrandEdit($get,[]);
                View::assign('find',$find);
                return View::fetch();
            }

            }




}